//
//  ByGetScoreFromPayDetailVC.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/8.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByGetScoreFromPayDetailVC.h"

// cell
#import "ByCellScoreStoreDetailHeader.h"        // 顶部商家信息
#import "ByCellScroeStoreDetailVipDay.h"        // 会员日
#import "ByCellScoreStoreDetailTransfer.h"      // 积分转化
#import "ByCellScoreStoreDetailAdvantage.h"     // 优势


@interface ByGetScoreFromPayDetailVC () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *table;

@end

@implementation ByGetScoreFromPayDetailVC

#pragma mark - vc生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"商家详情";
    
    [self addLeftBackBarButtonItem];
    
    [self createTableView];
}

#pragma mark - 创建视图
- (void)createTableView {
    
    self.table = [[UITableView alloc] init];
    self.table.backgroundColor = BY_BG_COLOR;
    self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.table.delegate = self;
    self.table.dataSource = self;
    [self.view addSubview:self.table];
    [self.table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(0, 0, 0, 0)).priorityMedium();
        if (@available(iOS 11.0, *)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-0);
            make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft);
            make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight);
        }
    }];
    
    
    
    [self.table registerClass:[ByCellScoreStoreDetailHeader class] forCellReuseIdentifier:@"headerInfoCell"];
    [self.table registerClass:[ByCellScroeStoreDetailVipDay class] forCellReuseIdentifier:@"vipCell"];
    [self.table registerClass:[ByCellScoreStoreDetailTransfer class] forCellReuseIdentifier:@"transferCell"];
    [self.table registerClass:[ByCellScoreStoreDetailAdvantage class] forCellReuseIdentifier:@"advantageCell"];

}


#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        ByCellScoreStoreDetailHeader *cell = [tableView dequeueReusableCellWithIdentifier:@"headerInfoCell"];
        return cell;
    }
    else if (indexPath.section == 1) {
        ByCellScroeStoreDetailVipDay *cell = [tableView dequeueReusableCellWithIdentifier:@"vipCell"];
        cell.vipContents = @[@"会员享受七折优惠", @"会员享受七折优惠", @"会员享受七折优惠会员享受七折优惠会员享受七折优惠会员享受七折优惠"];
        return cell;
    }
    else if (indexPath.section == 2) {
        ByCellScoreStoreDetailTransfer *cell = [tableView dequeueReusableCellWithIdentifier:@"transferCell"];
        return cell;
    }
    else if (indexPath.section == 3) {
        ByCellScoreStoreDetailAdvantage *cell = [tableView dequeueReusableCellWithIdentifier:@"advantageCell"];
        return cell;
    }
    return [UITableViewCell new];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        return [tableView fd_heightForCellWithIdentifier:@"headerInfoCell" cacheByIndexPath:indexPath configuration:^(id cell) {
            
        }];
    }
    else if (indexPath.section == 1) {
        return [tableView fd_heightForCellWithIdentifier:@"vipCell" cacheByIndexPath:indexPath configuration:^(ByCellScroeStoreDetailVipDay *cell) {
            cell.vipContents = @[@"会员享受七折优惠", @"会员享受七折优惠", @"会员享受七折优惠会员享受七折优惠会员享受七折优惠会员享受七折优惠"];
        }];
    }
    else if (indexPath.section == 2) {
        return [tableView fd_heightForCellWithIdentifier:@"transferCell" cacheByIndexPath:indexPath configuration:^(ByCellScoreStoreDetailTransfer *cell) {
        }];
    }
    else if (indexPath.section == 3) {
        return [tableView fd_heightForCellWithIdentifier:@"advantageCell" cacheByIndexPath:indexPath configuration:^(ByCellScoreStoreDetailAdvantage *cell) {
        }];
    }
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return UIView.new;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return UIView.new;
}

#pragma mark - getter

@end
